﻿using Microsoft.Extensions.Caching.Memory;

namespace HelperCommon.AOP.MemoryCache
{
    public class MemoryCaching : IMemoryCaching
    {
        private IMemoryCache _cache;

        //还是通过构造函数的方法，获取
        public MemoryCaching(IMemoryCache cache)
        {
            _cache = cache;
        }

        public object Get(string cacheKey)
        {
            return _cache.Get(cacheKey);
        }

        public void Set(string cacheKey, object cacheValue)
        {
            _cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(900));
        }
    }
}